<?php
	class Admin_Model_Slideshow extends Zend_Db_Table_Abstract{
		protected $_name = 'Slideshow';
		protected $_primary = 'id';
		
		public function getAll(){
			$select = $this->select()
						->order("id Desc");
			$result = $this->fetchAll($select);
			return $result->toArray();
		}
		public function getInfo($id){ 
			$select = $this->select()
						->where("id = ? ",$id);
			$result = $this->fetchRow($select);
			return $result->toArray();
		}
		public function addItem($data){
			try {
	        	$id = $this->insert($data);
	
	    		return $id;
			} catch (Exception $e) {
				throw $e;
			}
		}
		public function editItem($id,$data){
			try {
	        	$result = $this->update($data,"id = " . $id);
	    		return $result;
			} catch (Exception $e) {
				throw $e;
			}
			
		}
		public function deleteItem($id){
			if($result = $this->getInfo($id)){
				$fileupload = new My_File_Upload();
				$fileupload->removeFile(UPLOAD_PATH."/slideshow/".$result['image']);
				$this->delete(array('id'=>$id));
				return TRUE;
			}
			else{
				return FALSE;
			}
		}
	}
?>